package org.sunshine.miracle;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class SystemConfiguration {

    private static String CONFIGURATION_PATH = "/configuration.properties";

    private static Properties configuration;

    public static String getValue(String key) {
        if (configuration == null) {
            loadConfiguration();
        }
        return configuration.getProperty(key);
    }

    private static void loadConfiguration() {
        try {
            InputStream inputStream = Commons.getFileAsInputStream(CONFIGURATION_PATH);
            if (inputStream == null) throw new IllegalStateException("Cannot get configuration file.");
            configuration = new Properties();
            configuration.load(inputStream);
        } catch (IOException e) {
            throw new IllegalStateException("Cannot get configuration file.", e);
        }
    }



}
